<template>
  <div :class="$style.finance">
    <div style="text-align:right">
      <Button type="primary" @click="$refs.table.showSetting = true">设置表格样式</Button>
    </div>
    <table-box ref="table" :other-filters="filtersRaw" no-request :table-config="tableConfig" />
  </div>
</template>
<script>
export default {
  name: 'Finance',
  components: {
  },
  data() {
    return {
      filtersRaw: [],
      tableConfig: {
        interfacePath: '/call-center/api/v1/callLog/page',
        hideFuncBar: false,
        tabIndex: 3,
        sort: 'callDate',
        order: 'desc',
        // 表格字段动态配置
        setting: [
          {
            label: '序号',
            align: 'center',
            minWidth: '80',
            formatData: v => v.keyIndex + 1
          },
          {
            prop: 'callCode',
            minWidth: '155',
            label: '通话记录编号'
          },
          {
            prop: 'callPlatform',
            minWidth: '120',
            label: '话务平台',
            propEnum: {
              domainCode: 'marketing',
              appCode: 'call-center',
              dictTypeCode: 'CALL_PLATFORM'
            }
          },
          {
            prop: 'callSource', // TODO:外呼路径
            minWidth: '120',
            label: '外呼路径',
            propEnum: {
              appCode: 'call-center',
              domainCode: 'marketing',
              dictTypeCode: 'CALLOUT_TYPE'
            }
          },
          {
            prop: 'customerName',
            minWidth: '100',
            label: '客户姓名'
          },
          {
            prop: 'customerPhone',
            minWidth: '100',
            label: '联系电话'
          },
          {
            prop: 'callType',
            minWidth: '100',
            label: '呼叫类型',
            propEnum: {
              appCode: 'call-center',
              domainCode: 'marketing',
              dictTypeCode: 'CALL_TYPE'
            }
          },
          {
            prop: 'transfer',
            minWidth: '100',
            label: '转接类型',
            formatData: v => {
              let t = v.transfer
              if (t === undefined || t.toString() === '' || t.toString() === '0') return '未转接'
              t = t.toString()
              if (t === '1') return '转出'
              if (t === '2') return '转入'
            }
          },
          {
            prop: 'callTopic',
            minWidth: '100',
            label: '外呼事宜',
            propEnum: {
              appCode: 'call-center',
              domainCode: 'marketing',
              dictTypeCode: 'OUTBOUND_MATTERS'
            }
          },
          {
            prop: 'sapCode',
            minWidth: '100',
            label: 'SAP编码'
          },
          {
            prop: 'bpmCode',
            minWidth: '100',
            label: 'BPM编码'
          },
          {
            prop: 'content',
            minWidth: '100',
            label: '内容备注'
          },
          {
            prop: 'callDate',
            minWidth: '140',
            label: '通话时间'
          },
          {
            prop: 'talkTime',
            minWidth: '100',
            label: '通话时长',
            formatData: v => `${v.talkTime}s`
          },
          {
            prop: 'callerName',
            minWidth: '160',
            label: '坐席姓名',
            formatData: v => {
              let str = `${v.callerName}(${v.createBy})`
              if (v.callerPlatformNo) {
                str += ` - ${v.callerPlatformNo}`
              }
              return str
            }
          },
          {
            prop: 'localNumber',
            minWidth: '100',
            label: '本地号码'
          },
          {
            prop: 'extensionNumber',
            minWidth: '100',
            label: '分机号'
          },
          {
            prop: 'prefix',
            minWidth: '100',
            label: '外呼前缀'
          },
          {
            prop: 'satisfaction',
            minWidth: '100',
            label: '满意度',
            propEnum: {
              appCode: 'call-center',
              domainCode: 'marketing',
              dictTypeCode: 'SATISFACTION' // FIXME:
            }
          },
          {
            prop: 'releaseCause',
            minWidth: '100',
            label: '挂机原因',
            propEnum: {
              appCode: 'call-center',
              domainCode: 'marketing',
              dictTypeCode: 'RELEASE_CAUSE'
            }
          },
          {
            label: '操作',
            prop: 'operation',
            align: 'center',
            minWidth: '165',
            button: [
              {
                name: '电脑放音',
                clickFun: this.$parent.$parent.$parent.palyAudio.bind(this)
              },
              {
                name: '话机放音',
                clickFun: this.$parent.$parent.$parent.playPhone.bind(this)
              },
              {
                name: '下载',
                clickFun: this.$parent.$parent.$parent.downAudio.bind(this)
              }
            ]
          }

        ],
        btnList: [
          {
            buttonName: '启用',
            optCode: 'enable'
          },
          {
            buttonName: '禁用',
            optCode: 'forbidden'
          }
        ]
      }
    }
  },
  methods: {
    // 发起查询请求
    initData(filtersRaw) {
      this.filtersRaw = filtersRaw
      this.$nextTick(() => {
        this.$refs.table.initTableData()
      })
    }
  }
}
</script>
<style lang='scss' module>
.finance{

}
</style>
